#include<bits/stdc++.h>
using namespace std;
long long n,a[10010],k[10010];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a,a+n+1);
    for(int i=2;i<=n;i++){
       if(a[i]>a[i-1]) k[a[i-1]]=n-i+1;
    }
    for(int i=1;i<=n;i++){
        if(k[a[i]]!=0) k[a[i]]--;
        if(k[a[i]]==0) {
            cout<<n-i;
            return 0;
        }
    }

}
